<template>
  <div class="mytest">
    <h1>使用cookie</h1>
    <div><button @click="fn1">设置 cookie</button></div>
    <div><button @click="fn2">获取 cookie</button></div>
    <div><button @click="fn3">删除 cookie</button></div>
  </div>
</template>

<script>
import cookie from 'js-cookie'
export default {
  methods: {
    // 设置 cookie
    fn1() {
      // 保存 cookie
      //  key： name   value： 刘亦菲
      // cookie.set(key, value)
      cookie.set('name', 'liuyifei')
    },
    fn2() {
      // 获取 cookie
      // cookie.get(key)
      const res = cookie.get('name')
      console.log(res)
    },
    fn3() {
      // 删除 cookie
      cookie.remove('name')
    }
  }
}
</script>

<style></style>
